//
//  BIBluetoothModel.h
//  BIBluetoothModule
//
//  Created by Yown on 2024/1/21.
//

#import "BIBluetoothCMD.h"
#import "BIBluetoothDeviceModel.h"

#import <BIProjectModule/BIModel.h>
#import <CoreBluetooth/CoreBluetooth.h>

typedef NS_ENUM(NSUInteger, BIBluetoothState) {
    kBIBluetoothDisconnected = 0,
    kBIBluetoothConnecting,
    kBIBluetoothConnected,
};

@interface BIBluetoothModel : BIModel

/// 蓝牙连接状态
@property (nonatomic, assign) BIBluetoothState state;
/// 蓝牙连接时间，用于控制超时，当状态变为kBIBluetoothConnecting开始计时
@property (nonatomic, assign) NSUInteger connectTimeInterval;
/// 蓝牙设备
@property (nonatomic) CBPeripheral *peripheral;
/// 蓝牙写特征
@property (nonatomic) CBCharacteristic *writeCharacteristic;
/// 蓝牙读特征
@property (nonatomic) CBCharacteristic *readCharacteristic;
/// 蓝牙名字
@property (nonatomic, copy) NSString *name;
/// 蓝牙UUID
@property (nonatomic, copy) NSString *uuid;
/// 蓝牙自定义数据包，一般都是mac地址
@property (nonatomic, copy) NSString *manufacturer;
/// 标准的mac地址,长度17，中间用：隔开
@property (nonatomic, copy, readonly) NSString *macAddress;
/// 蓝牙连接时间/多个蓝牙时也可表示该蓝牙设备的最后一次选中时间
@property (nonatomic, assign) NSTimeInterval selectTimeInterval;
/// 蓝牙设备图，网络请求来的，可能为空
@property (nonatomic, copy) NSString *deviceImageURL;

/// 蓝牙数据的指令类，如获取电量等(这个类声明设备指令，具体指令由子类实现)
@property (nonatomic) BIBluetoothCMD *cmdModel;
/// 蓝牙数据的解析类，如电量等(这个类声明设备属性，解析由子类实现)
@property (nonatomic) BIBluetoothDeviceModel *deviceModel;

/// 断开蓝牙时调用，用于清除信息
- (void)disconnectBluetooth;

@end
